<?php
/**
 * User: bim bip
 * Date: 8/5/11
 * Time: 12:38 PM
 */
if(!defined('BASEPATH')) exit('No direct script access allowed');
if(!function_exists('')){
    function pageArray($show, $maxPage, $currentPage){
        $pageArr = array();
        if($currentPage == 1)
            for($i = 1; $i <= $show+1 && $i <= $maxPage; $i++)
                $pageArr[] = $i;
        else if($currentPage == $maxPage){
            $before = $currentPage - $show;
            if($before <= 0) $before = 1;
            for($i = $before; $i <= $maxPage; $i++)
                $pageArr[] = $i;
        }
        else{
            //get before
            $before = $currentPage - $show;
            if($before <= 0) $before = 1;
            //get after
            $after = $currentPage + $show;
            if($after > $maxPage) $after = $maxPage;
            //show
            for($i = $before; $i <= $after; $i++)
                $pageArr[] = $i;
        }
        return $pageArr;
    }
}
